package com.gangquan360.smartadmin.module.supplier.controller;

import com.gangquan360.smartadmin.common.anno.NoValidPrivilege;
import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.constant.SwaggerTagConst;
import com.gangquan360.smartadmin.module.supplier.domain.dto.SupplierCategoryDTO;
import com.gangquan360.smartadmin.module.supplier.domain.dto.SupplierCategoryQueryDTO;
import com.gangquan360.smartadmin.module.supplier.service.SupplierCategoryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import javax.validation.Valid;

/**
 * [ 供应商分类表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-14 13:55:51
 * @since JDK1.8
 */
@RestController
@Api(tags = {SwaggerTagConst.Group2.SUPPLIER_CATEGORY_MANGER})
public class SupplierCategoryController {

    @Autowired
    private SupplierCategoryService supplierCategoryService;

    @ApiOperation(value = "分页查询供应商分类表",notes = "@author wiggin")
    @PostMapping("/supplier/category/page/query")
    public ResponseDTO<PageResultDTO<SupplierCategoryDTO>> queryByPage(@RequestBody SupplierCategoryQueryDTO queryDTO) {
        return supplierCategoryService.queryByPage(queryDTO);
    }
    
   @ApiOperation("供应商列表")
   @GetMapping("/supplier/category/list")
   @NoValidPrivilege
    public ResponseDTO<List<SupplierCategoryDTO>> queryList() {
    	return supplierCategoryService.queryList();
    }
   

    @ApiOperation(value = "添加供应商分类表",notes = "@author wiggin")
    @PostMapping("/supplier/category/add")
    public ResponseDTO<String> add(@RequestBody @Valid SupplierCategoryDTO addTO){
        return supplierCategoryService.add(addTO);
    }

    @ApiOperation(value="修改供应商分类表",notes = "@author wiggin")
    @PostMapping("/supplier/category/update")
    public ResponseDTO<String> update(@RequestBody @Valid SupplierCategoryDTO updateDTO){
        return supplierCategoryService.update(updateDTO);
    }


    @ApiOperation(value="删除供应商分类表",notes = "@author wiggin")
    @GetMapping("/supplier/category/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return supplierCategoryService.delete(id);
    }


    @ApiOperation(value="详情供应商分类表",notes = "@author wiggin")
    @GetMapping("/supplier/category/detail/{id}")
    public ResponseDTO<SupplierCategoryDTO> detail(@PathVariable("id") Long id){
        return supplierCategoryService.detail(id);
    }
}
